package com.pb.metadata.controller;


import com.pb.infra.oth.entity.common.Page;
import com.pb.infra.oth.entity.common.Result;
import com.pb.infra.oth.util.Constant;
import com.pb.infra.oth.util.SysLog;
import com.pb.metadata.service.DimensionNoManagementService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 维度编号管理
 * @author weiziyu
 */

@Slf4j
@RestController
@RequestMapping("v1/alm/dimensionNoManagement")
public class DimensionNoManagementController {
    /**
     * 业务逻辑对象
     */
    @Resource
    private DimensionNoManagementService dimensionNoManagementService;

    /**
     * 日志操作表
     */
    private static final String TABLE_NAME = "param_dimm_type";

    /**
     * 日志操作功能名
     */
    private static final String OPERATION_MENU = "维度编号管理";

    /**
     * 查询分页数据
     * @param map 查询参数
     * @param page 页码
     * @return Result 返回数据
     */
    @GetMapping("select")
    @SysLog(tableName = TABLE_NAME, action = Constant.ACTION_NAME.QUERY, menuName = OPERATION_MENU)
    public Result select(@RequestParam Map<String, Object> map, Page page) {
        return dimensionNoManagementService.select(map, page);
    }

    @PostMapping("addDimNoData")
    @SysLog(tableName = TABLE_NAME, action = Constant.ACTION_NAME.QUERY, menuName = OPERATION_MENU)
    public Result addDimNoData(@RequestBody Map<String, Object> paramMap) {
        return dimensionNoManagementService.addDimNoData(paramMap);
    }

    @PostMapping("delDimNoData")
    @SysLog(tableName = TABLE_NAME, action = Constant.ACTION_NAME.QUERY, menuName = OPERATION_MENU)
    public Result delDimNoData(@RequestBody Map<String, Object> paramMap) {
        return dimensionNoManagementService.delDimNoData(paramMap);
    }

    @PostMapping("updateDimNoData")
    @SysLog(tableName = TABLE_NAME, action = Constant.ACTION_NAME.QUERY, menuName = OPERATION_MENU)
    public Result updateDimNoData(@RequestBody Map<String, Object> paramMap) {
        return dimensionNoManagementService.updateDimNoData(paramMap);
    }

    @PostMapping("getComDimAttrRegDataByDimNo")
    @SysLog(tableName = TABLE_NAME, action = Constant.ACTION_NAME.QUERY, menuName = OPERATION_MENU)
    public Result getComDimAttrRegDataByDimNo(@RequestBody Map<String, Object> map) {
        return dimensionNoManagementService.getComDimAttrRegDataByDimNo(map);
    }

    //修改维度属性注册数据
    @PostMapping("updateComDimAttrRegData")
    @SysLog(tableName = TABLE_NAME, action = Constant.ACTION_NAME.QUERY, menuName = OPERATION_MENU)
    public Result updateComDimAttrRegData(@RequestBody Map<String, Object> paramMap) {
        return dimensionNoManagementService.updateComDimAttrRegData(paramMap);
    }

    // 查询公共关联码值列表
    @GetMapping("getComRelaStdCodeList")
    @SysLog(tableName = "PARAM_CODE_TYPE", action = Constant.ACTION_NAME.QUERY, menuName = OPERATION_MENU)
    public Result getComRelaStdCodeList(@RequestParam Map<String, Object> map) {
        return dimensionNoManagementService.getComRelaStdCodeList(map);
    }

    //删除公共维度属性注册数据
    @PostMapping("delComAttrRegData")
    @SysLog(tableName = TABLE_NAME, action = Constant.ACTION_NAME.QUERY, menuName = OPERATION_MENU)
    public Result delComAttrRegData(@RequestBody List<Map<String,Object>> AttrRegList) {
        return dimensionNoManagementService.delComAttrRegData(AttrRegList);
    }

    //增加公共维度属性注册数据
    @PostMapping("addComDimAttrRegData")
    @SysLog(tableName = TABLE_NAME, action = Constant.ACTION_NAME.QUERY, menuName = OPERATION_MENU)
    public Result addComDimAttrRegData(@RequestBody Map<String, Object> paramMap) {
        return dimensionNoManagementService.addComDimAttrRegData(paramMap);
    }

    //校验新增公共维度属性编码是否唯一
    @PostMapping("validUnique")
    @SysLog(tableName = TABLE_NAME, action = Constant.ACTION_NAME.QUERY, menuName = OPERATION_MENU)
    public Result validUnique(@RequestBody Map<String, Object> paramMap) {
        return dimensionNoManagementService.validUnique(paramMap);
    }

    //修改统一管理状态
    @PostMapping("updateUnifyFlag")
    @SysLog(tableName = TABLE_NAME, action = Constant.ACTION_NAME.QUERY, menuName = OPERATION_MENU)
    public Result updateUnifyFlag(@RequestBody Map<String, Object> paramMap) {
        return dimensionNoManagementService.updateUnifyFlag(paramMap);
    }

}
